package com.example.demo;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * 完成对Redis整合的配置
 *
 * @author 机械革命
 */
@Configuration
public class RedisConfig {

    @Autowired
    JedisPoolConfig config;

    @Bean
    public JedisPoolConfig jedisPoolConfig() {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(50);
        config.setMaxIdle(10);
        config.setMaxIdle(10);
        config.setMinIdle(5);
        config.setMaxTotal(20);
        return config;
    }

    @Bean
    public JedisPool jedisPool() {
        return new JedisPool(config, "111.229.219.16", 6379, 1000, "peter@2019");
    }
}